package com.uidt.project.ptsj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.uidt.framework.aspectj.lang.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uidt.framework.aspectj.lang.annotation.Log;
import com.uidt.framework.aspectj.lang.enums.BusinessType;
import com.uidt.project.ptsj.domain.PtsjScreenDzzd;
import com.uidt.project.ptsj.service.IPtsjScreenDzzdService;
import com.uidt.framework.web.controller.BaseController;
import com.uidt.framework.web.domain.AjaxResult;
import com.uidt.common.utils.poi.ExcelUtil;
import com.uidt.framework.web.page.TableDataInfo;

/**
 * 党政主导
Controller
 * 
 * @author uidt
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/ptsj/dzzd")
public class PtsjScreenDzzdController extends BaseController
{
    @Autowired
    private IPtsjScreenDzzdService ptsjScreenDzzdService;

    /**
     * 查询党政主导列表
     */
//    @Anonymous
//    @PreAuthorize("@ss.hasPermi('ptsj:dzzd:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtsjScreenDzzd ptsjScreenDzzd)
    {
        startPage();
        List<PtsjScreenDzzd> list = ptsjScreenDzzdService.selectPtsjScreenDzzdList(ptsjScreenDzzd);
        return getDataTable(list);
    }


    /**
     * 获取当前有效的数据，只有一条
     */
    @Anonymous
    @GetMapping("/getCurrent")
    public AjaxResult getCurrent()
    {
        PtsjScreenDzzd dzzd = new PtsjScreenDzzd();
        dzzd.setDel("0");
        List<PtsjScreenDzzd> list = ptsjScreenDzzdService.selectPtsjScreenDzzdList(dzzd);
        if(list!=null && list.size()>0){
            return AjaxResult.success(list.get(0));
        }else{
            return AjaxResult.success();
        }
    }


    /**
     * 导出党政主导列表
     */
    @PreAuthorize("@ss.hasPermi('ptsj:dzzd:export')")
    @Log(title = "党政主导", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PtsjScreenDzzd ptsjScreenDzzd)
    {
        List<PtsjScreenDzzd> list = ptsjScreenDzzdService.selectPtsjScreenDzzdList(ptsjScreenDzzd);
        ExcelUtil<PtsjScreenDzzd> util = new ExcelUtil<PtsjScreenDzzd>(PtsjScreenDzzd.class);
        util.exportExcel(response, list, "党政主导数据");
    }

    /**
     * 获取党政主导详细信息
     */
//    @PreAuthorize("@ss.hasPermi('ptsj:dzzd:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(ptsjScreenDzzdService.selectPtsjScreenDzzdById(id));
    }

    /**
     * 新增党政主导

     */
//    @PreAuthorize("@ss.hasPermi('ptsj:dzzd:add')")
    @Log(title = "党政主导", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtsjScreenDzzd ptsjScreenDzzd)
    {
        return toAjax(ptsjScreenDzzdService.insertPtsjScreenDzzd(ptsjScreenDzzd));
    }

    /**
     * 修改党政主导

     */
//    @PreAuthorize("@ss.hasPermi('ptsj:dzzd:edit')")
    @Log(title = "党政主导", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtsjScreenDzzd ptsjScreenDzzd)
    {
        return toAjax(ptsjScreenDzzdService.updatePtsjScreenDzzd(ptsjScreenDzzd));
    }

    /**
     * 删除党政主导

     */
//    @PreAuthorize("@ss.hasPermi('ptsj:dzzd:remove')")
    @Log(title = "党政主导", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(ptsjScreenDzzdService.deletePtsjScreenDzzdByIds(ids));
    }
}
